package com.bwf.lgqingdan.mvp.presenter.impl;

import com.bwf.lgqingdan.entity.ThingsBean;
import com.bwf.lgqingdan.mvp.model.SearchThingListModel;
import com.bwf.lgqingdan.mvp.model.impl.SearchThingListModelImpl;
import com.bwf.lgqingdan.mvp.presenter.SearchThingListPresenter;
import com.bwf.lgqingdan.mvp.view.SearchDataListView;

import java.util.List;

/**
 * Created by Administrator on 2016/11/21.
 */

public class SearchThingPresenterImpl implements SearchThingListPresenter, SearchThingListModel.Callback {
    private SearchThingListModel model;
    private SearchDataListView view;

    public SearchThingPresenterImpl(SearchDataListView view) {
        this.view = view;
        this.model = new SearchThingListModelImpl();
    }

    @Override
    public void loadData(String keyword) {

        model.loadData(keyword,this);
    }

    @Override
    public void loadSuccess(List<ThingsBean> things) {
        view.hideLoading();
        if(things == null || things.size() == 0){
            view.clearListDatas();
            view.showNoDataLayout();
        }else{
            view.showData(things);
            view.hideNoDataLayout();
        }
    }

    @Override
    public void loadFailed(String failedMsg) {

    }
}
